{include file="common/header"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form layui-form-pane" lay-filter="form">
                        <input type="hidden" name="id">
                        <div class="layui-form-item">
                            <label class="layui-form-label">标识</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" lay-verify="required|letter" placeholder="标识" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux red">* 只能由英文、数字、下划线组成</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">广告名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="title" lay-verify="required" placeholder="{:lang('pleaseEnter')}广告名称" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">广告图片</label>
                            <input type="hidden" name="image" id="pic" class="attach" >
                            <div class="layui-input-block">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn layui-btn-primary" id="selectAttach" data-href="{:url('sys.attach/select')}?mime=image"><i class="icon icon-upload3"></i>选择</button>
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" style="width: 120px; height: 100px;" id="adPic">
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">{:lang('ad')}URL</label>
                            <div class="layui-input-inline">
                                <input type="text" name="url" placeholder="{:lang('pleaseEnter')}{:lang('ad')}URL" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="status" value="normal" checked title="正常">
                                <input type="radio" name="status" value="hidden" title="隐藏">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">{:lang('order')}</label>
                            <div class="layui-input-inline">
                                <input type="text" name="sort" placeholder="从小到大排序" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">内容</label>
                            <div class="layui-input-inline">
                                <textarea placeholder="请输广告内容" name="content" class="layui-textarea"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="common/footer"/}
<script>
    layui.use(['form', 'layer','upload'], function () {
        var form = layui.form, $ = layui.jquery, upload = layui.upload;
        form.verify({
            letter: [
                /^\w+$/
                ,'只能由英文、数字、下划线组成'
            ] 
        });    
        var info = '';
        info = {:json_encode($info)};
        form.val("form", info);
        if(info){
            $('#adPic').attr('src',info.image);
        }
        form.render();
    });
</script>